import 'package:extended_tabs/extended_tabs.dart';
import 'package:flutter/material.dart';
import 'package:live_music/pages/home/square/page_view/file_note_square.dart';
import 'package:live_music/pages/home/square/page_view/image_note_square.dart';
import 'package:live_music/pages/home/square/page_view/moment_note_square.dart';
import 'package:live_music/pages/home/square/page_view/video_note_square.dart';
import 'package:live_music/utils/colors.dart';

class NoteSquare extends StatefulWidget {
  NoteSquare({Key key}) : super(key: key);

  @override
  _NoteSquareState createState() => _NoteSquareState();
}

class _NoteSquareState extends State<NoteSquare>
    with SingleTickerProviderStateMixin {
  TabController _tabController;
  final List<Widget> _tabsContent = [
    MomentNoteSquare(),
    VideoNoteSquare(),
    ImageNoteSquare(),
    FileNoteSquare()
  ];
  final List<Widget> _tabs = [Text('动态'), Text('视频'), Text('图片'), Text('文件')];
  @override
  void initState() {
    super.initState();
    _tabController = TabController(
      initialIndex: 0,
      length: _tabs.length,
      vsync: this,
    );
  }

  @override
  Widget build(BuildContext context) {
    double screenWidth = MediaQuery.of(context).size.width;
    return Column(mainAxisSize: MainAxisSize.max, children: [
      Row(mainAxisSize: MainAxisSize.max, children: [
        Container(
            alignment: Alignment.centerLeft,
            padding: EdgeInsets.symmetric(horizontal: 10, vertical: 10),
            width: 0.7 * screenWidth,
            child: ExtendedTabBar(
              indicatorSize: TabBarIndicatorSize.label,
              controller: _tabController,
              indicatorColor: ColorRes.tabLine,
              indicatorWeight: 2,
              unselectedLabelStyle: TextStyle(
                color: Colors.grey[600], // 下划线颜色
                fontSize: 14,
              ),
              labelStyle: TextStyle(
                color: Colors.white,
                fontSize: 14,
              ), //标签文字大小颜色
              tabs: _tabs,
            )),
      ]),
      Expanded(
          child: ExtendedTabBarView(
        controller: _tabController,
        children: _tabsContent,
      ))
    ]);
  }
}
